package tests;

import main.*;
import org.junit.Test;
import org.junit.Before;
import static org.junit.Assert.*;

public class NotationTest {
	Operation ex;

	@Before
	public void init() {
		ex = new Times(
				new Minus(
					new Plus(5, 3), 
					new Times(
						new MyNumber(8), 
						new Minus(7, 6))), 
				new MyNumber(2));
	}

	@Test
	public void prefix() {
		Operation.notation = Notation.PREFIX;
		assertEquals("* 2 3", new Times(2,3).toString());
	}

	@Test
	public void prefixHard() {
		Operation.notation = Notation.PREFIX;
		assertEquals("* (- (+ 5 3) (* 8 (- 7 6))) 2", ex.toString());
	}

	@Test
	public void infix() {
		Operation.notation = Notation.INFIX;
		assertEquals("2 * 3", new Times(2,3).toString());
	}

	@Test
	public void infixHard() {
		Operation.notation = Notation.INFIX;
		assertEquals("((5 + 3) - (8 * (7 - 6))) * 2", ex.toString());
	}

	@Test
	public void postfix() {
		Operation.notation = Notation.POSTFIX;
		assertEquals("2 3 *", new Times(2,3).toString());
	}

	@Test
	public void postfixHard() {
		Operation.notation = Notation.POSTFIX;
		assertEquals("((5 3 +) (8 (7 6 -) *) -) 2 *", ex.toString());
	}
}
